// pages/user/page/myFeedback/userSendEmail/userSendEmail.js

const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    phone:null,
    name:null,
    content:null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(app.userDate.userInfo)
    this.setData({
      phone:app.userDate.userInfo.userPhone,
      name:app.userDate.userInfo.userName
    })
  },
  submitFeedback:function(e){
    console.log(e)
    let _content = e.detail.value.content
    if(_content==''){
      wx.showToast({
        title: '反馈不能为空',
        icon:"none"
      })
    }else{
    let that = this
    wx.cloud.callFunction({
      name:'sendEmail',
      data:{
        phone:that.data.phone,
        name:that.data.name,
        content:_content
      },success: res => {
        console.log(res)
        wx.showToast({  
          title: '发送成功',  
          icon: 'success',  
          duration: 2000  
      })   
      },
      fail: err => {
        console.log(err)
      }
    })
  }
  },
  
})